#ifndef __AOT_DATA_OP_RECV_FILE_RECORD_OP_H__    
#define __AOT_DATA_OP_RECV_FILE_RECORD_OP_H__

#include <interface/data_op/recv_file_record.h>

namespace aot{ namespace data{

class recv_file_info_impl : public irecv_file_info
{
public:
    virtual ~recv_file_info_impl(){;}
    recv_file_info_impl()
    {
        id = 0;
        size = 0;
        flag = 0;

		file_name = &file_name_impl;
		sender_id = &sender_id_impl; 
		sender_name = &sender_name_impl;
		recv_time = &recv_time_impl;
		file_path = &file_path_impl;
    }
public:
    virtual  bool clone(irecv_file_info** out) 
    {
        recv_file_info_impl* p = new recv_file_info_impl();
        *out = p;
        return p->assign(this);
    }
    virtual  bool assign(const irecv_file_info* in) 
    {
        if (NULL==in)
            return false;

        recv_file_info_impl* p = (recv_file_info_impl*) in;
        *this = *p;

        file_name = &file_name_impl;
        sender_id = &sender_id_impl; 
        sender_name = &sender_name_impl;
        recv_time = &recv_time_impl;
        file_path = &file_path_impl;
        return true;
    }
public:

    aot::tt::str_impl file_name_impl;
    aot::tt::str_impl sender_id_impl; 
    aot::tt::str_impl sender_name_impl;
    aot::tt::str_impl recv_time_impl;
    aot::tt::str_impl file_path_impl;
};


class recv_file_record_op_impl : public aot::data::irecv_file_record_op
{
public:
    recv_file_record_op_impl(void);
public:
    virtual ~recv_file_record_op_impl(void);
public:    
	virtual bool insert(const irecv_file_info* p, int* new_id);
	virtual bool del(int id); 
	virtual bool update(const irecv_file_info* p);
	///
	virtual bool read(int id, isqlite3_table** out);
	virtual bool read(int id, irecv_file_info* out);
	virtual bool read(int id, irecv_file_info** out);

	virtual int get_count_by_key(const char*  sender_name, const char* file_name);
	virtual bool get_page_records_by_key(const char* sender_name, const char* file_name, int count_per_page, int page_index, isqlite3_table** out);

	virtual int get_count_by_user_id(const char*  user_id);
	virtual bool get_page_records_by_user_id(const char* user_id, int count_per_page, int page_index, isqlite3_table** out);

	virtual int get_all_count();
	virtual bool get_page_records(int count_per_page, int page_index, isqlite3_table** out);
};

}} /* end namespace aot/data*/

#endif 
